import QtQuick 2.2
import QtQuick.Controls 1.1
import "../FKWidget/"

FKWidget{
    id: langWidget
    relativeWidth: 0.6
    relativeHeight: 0.7
    property int countButtons:0
    readonly property int spacerItemHeight:viewport.height/(countButtons+1)

    function addLang(lng,lngLbl){
        listModel.append({"lang":lng,"langStr":lngLbl});
        ++countButtons;
    }
    signal languageChosen(var lng)
    onLanguageChosen: hide()
    Component{
        id: langDelegate
        Item{
            height: spacerItemHeight
            anchors.left: parent.left
            anchors.right: parent.right
            Button{
                property string langID: lang
                text: langStr
                width: parent.width*0.9
                anchors.centerIn: parent
                onClicked: langWidget.languageChosen(langID)
            }
        }
    }
    ListModel{id: listModel}
    FKViewport{
        id:viewport
        ListView{
            delegate: langDelegate
            model: listModel
            anchors.fill: parent
            anchors.topMargin: spacerItemHeight/2
            anchors.bottomMargin: spacerItemHeight/2
            interactive: false
        }
    }
}
